<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
		<title>查报告</title>
		<meta http-equiv="expires" content="0">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<link rel="stylesheet" href="../../css/reset.css" />
		<link rel="stylesheet" href="../../css/mui.min.css" />
		<link rel="stylesheet" href="../../css/iconfont.css" />
		<link rel="stylesheet" href="../../css/cmms.css" />
		<link rel="stylesheet" type="text/css" href="../../css/mui.picker.min.css"/>
		<link rel="stylesheet" href="../../css/hopistal/reportSearch.css"/>
	</head>
	<style type="text/css">
		
	</style>
	<body>
		<div class="mui-content" id="reportSearch" v-cloak>
		    <div class="wrap">
		    	<div class="contain">
		    		<p>报告单自助查询</p>
		    		<div class="panel">
		    			<ul>
		    				<li class="mui-table-view-cell"><span>患者姓名：</span><input type="text" v-model="patientName" placeholder="请输入患者姓名"/></li>
							<li class="mui-table-view-cell">
								<span>检验条形码：</span>
								<input type="number" placeholder="请输入检验条形码" name="reportSearch" v-model="barCode" />
							</li>
							<li class="mui-table-view-cell"><span>开始时间：</span><input type="text" v-model="startTime" @tap="selectStartTime" readonly unselectable="on" /></li>
							<li class="mui-table-view-cell"><span>结束时间：</span><input type="text" v-model="endTime" @tap="selectEndTime" readonly unselectable="on" /></li>
		    			</ul>
		    			<button @tap="search">查询</button>
		    		</div>
		    	</div>
		    </div>
		</div>
		<script src="../../js/mui.min.js"></script>
		<script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
		<script src="../../js/vue.js"></script>
		<script src="../../js/cmms.js?time=333"></script>
		<script src="../../js/jquery-2.1.4.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/mui.picker.min.js" type="text/javascript" charset="utf-8"></script>
		<script>
			new Vue({
				el:"#reportSearch",
				data:{
					barCode:'',
					patientName:'',
					startTime:'',
					endTime:'',
					hospitalCode:'',
					token:'',
					SampleInfo:[],
					nowTimeStamp:0,
					cacheTime:0
				},
				mounted(){
					this.init();
					this.getUrl();
				},
				methods:{
					init(){
						let _this = this;
						_this.token = localStorage.getItem('hospi_token');
//						_this.cacheTime = localStorage.getItem('cacheTime');
//						_this.nowTimeStamp = (new Date()).valueOf();
//						let temp = _this.nowTimeStamp-_this.cacheTime;
//						if(temp>=3600){
//							localStorage.removeItem('hospi_token');
//							localStorage.removeItem('cacheTime');
//						}
						
//						if(_this.token==''){
//							mui.alert("token已过期，请重新登录！");
//							location.href="../login-hopi.html";
//						}
						let nowDate = new Date();
						let y = nowDate.getFullYear();
						let m = nowDate.getMonth() + 1;
								    
						m = m<10?"0" + m:m;
						let d = nowDate.getDate();
						d = d<10?"0" + d:d;
						
						_this.startTime = y+'-'+m+'-'+d;
						_this.endTime = y+'-'+m+'-'+d;
//						console.log(_this.startTime);
					},
					/*获取URI后的hospitalCode*/
					getUrl(){
						let _this=this;
						var url = location.search; //获取url中"?"符后的字串    
						var theRequest = new Object();  
//						console.log(url);
					   	if (url.indexOf("?") != -1) {   
					      var str = url.substr(1);  
//					      console.log(str);
					      strs = str.split("&");  
					      for(var i = 0; i < strs.length; i ++) {   
					         theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);   
					      } 
					   	}   
//					   	console.log(theRequest);
					   	_this.hospitalCode = theRequest.hospitalCode;
					},
					
					selectStartTime(){
						let _this = this;
						var options = {"type":"date","beginYear":1900,"endYear":2100};
						picker = new mui.DtPicker(options);
						picker.show(function(rs) {
							console.log(rs);
							_this.startTime=rs.value;
							picker.dispose();
							picker = null;
						});
						
					},
					selectEndTime(){
						let _this = this;
						var options = {"type":"date","beginYear":1900,"endYear":2100};
						picker = new mui.DtPicker(options);
						picker.show(function(rs) {
							console.log(rs);
							_this.endTime=rs.value;
							picker.dispose();
							picker = null;
						});
					},
					search(){
						let _this = this;
						if(_this.startTime>_this.endTime){
							mui.alert("开始时间不能大于结束时间！");
							return false;
						}
						else{
							console.log(_this.barCode);
							console.log(_this.patientName);
							console.log(_this.startTime);
							console.log(_this.endTime);
							console.log(_this.hospitalCode);
							location.href="reportResult.html?Barcode="+_this.barCode+"&PatientName="+_this.patientName+"&BeginDate="+_this.startTime+"&EndDate="+_this.endTime+"&HospitalCode="+_this.hospitalCode;
						}
					}
				}
			})
		</script>
	</body>
</html>